package com.zq.assistant.ui.file;

import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.widget.ListView;

import com.zq.assistant.R;
import com.zq.assistant.ui.BaseActivity;
import com.zq.assistant.ui.file.adapter.FileDownloadAdapter;
import com.zq.assistant.ui.file.down.FileDownloadProvider;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by zhangqiang on 17-6-19.
 */

public class FileDownloadManagerActivity extends BaseActivity {


    @InjectView(R.id.toolbar)
    Toolbar toolbar;
    @InjectView(R.id.list_view)
    ListView listView;

    Cursor cursor;

    public static void start(Context context) {

        Intent intent = new Intent(context, FileDownloadManagerActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_file_download_manager);
        ButterKnife.inject(this);
        initToolbar(this,toolbar);

        cursor = getContentResolver().query(FileDownloadProvider.CONTENT_URI,null,null,null,null);

        FileDownloadAdapter adapter = new FileDownloadAdapter(this,cursor,true);
        listView.setAdapter(adapter);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(cursor != null){
            cursor.close();
        }
    }
}
